#!/bin/bash
set -e
MOTION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
export TZ=UTC

FASTFEATURE_ROOT=$FASTFEATUREPATH
if [ -z "$FASTFEATURE_ROOT" ]
then
  if [[ -d ~/workspace/coin_lm/fastfeature ]]; then
    FASTFEATURE_ROOT=~/workspace/coin_lm/fastfeature
  else
    FASTFEATURE_ROOT="$HOME/workspace/fastfeature"
  fi
fi

XUNKEDIR=$(readlink -f '../external/xunkemgmt/xunkemgmt/python')
export PYTHONPATH=$XUNKEDIR:$PYTHONPATH
BAZELDIR=$(readlink -f '../../coin_binary/coin2-bazel-bin')
export PYTHONPATH=$BAZELDIR:$PYTHONPATH

echo "using ${FASTFEATURE_ROOT}"
source ${FASTFEATURE_ROOT}/third_party/fastfeature/bin/envsetup.sh
source ${FASTFEATURE_ROOT}/coinstrat/bin/envsetup2.sh
source ../cc/envsetup.sh

echo $PYTHONPATH

unset FASTFEATURE_ROOT

cd "${MOTION_DIR}"
python "$@"
unset MOTION_DIR
